package com.shsubway.fragment;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;

import com.rengwuxian.materialedittext.MaterialEditText;
import com.shsubway.R;
import com.shsubway.adapter.QuesFragmentAdapter;
import com.shsubway.base.BaseFragment;
import com.shsubway.model.AnswerEntity;
import com.shsubway.model.QuestionEntity;
import com.shsubway.utils.ClearEditText;
import com.shsubway.utils.Constant;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;

/**
 * Created by Hu on 2017/3/2.
 */

public class QuestionFragment extends BaseFragment {
    @BindView(R.id.ans_list)
    RecyclerView ansList;
    @BindView(R.id.content_make_question)
    LinearLayout contentMakeQuestion;
    QuestionEntity questionEntity;
    List<AnswerEntity> answerEntityList;
    QuesFragmentAdapter quesFragmentAdapter;
    View heardView;
    TextView ands;
    int type;//type 0 为考试模式 1 为普通查看

    @Override
    public int getLayout() {
        return R.layout.recyclerview;
    }

    @Override
    public void initViews(View rootView) {
        ButterKnife.bind(this, rootView);
        initView();
    }

    private void initView() {
        answerEntityList = new ArrayList<>();
        initHeardView();
        initAdapter();
    }

    private void initAdapter() {
        setRecy(ansList);
        quesFragmentAdapter = new QuesFragmentAdapter(R.layout.item_show_question, questionEntity.getAnswerEntities(),type);
//        quesFragmentAdapter.setEmptyView(emptyView);
        ansList.setAdapter(quesFragmentAdapter);
        quesFragmentAdapter.addHeaderView(heardView);
        ands.setText(questionEntity.getQstcontent());

    }



    public void setQues(QuestionEntity questionEntity, int i) {
        this.questionEntity = questionEntity;
        this.type=i;
    }

    private void initHeardView() {
        heardView = View.inflate(context, R.layout.heard_ques_fragment, null);
        ands = $(R.id.ques_heard, heardView);
    }
}
